package com.xiaoy.core.base.security.user.action;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Results;

import com.xiaoy.core.base.security.role.service.RoleService;
import com.xiaoy.core.base.security.user.service.UserRoleService;
import com.xiaoy.core.base.security.user.service.UserService;
import com.xiaoy.web.BasicAction;

@Namespace("/base/security/userrole")
@Results({})
public class UserRoleAction extends BasicAction {
	
	@Resource
	private UserService us ;
	@Resource
	private RoleService rs ;
	
	@Resource
	private UserRoleService urs ;
	
	public String userSettingRole () {
		
		try {
			long[] roleIds=getParameterLongs("roleIds");
			long[] userIds = getParameterLongs("userIds");
			
			urs.userSettingRoles(userIds, roleIds);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return "userSettingRole";
	}
	
	public String list () {
		
		setAttribute("users", us.getUsers());
		setAttribute("roles", rs.getRoles());
		
		return "list";
	}
	
}


